var statistics = {
		init : function() {
			statistics.statisticsGrid = $('#statisticsGrid');
			statistics.statisticsUserName=$('#statistics-user-name');
			statistics.statisticsClazzName=$('#statistics-clazz-name');
			statistics.statisticsPaperName=$('#statistics-paper-name');
			statistics.statisticsGetPoint1=$('#statistics-get-point1');
			statistics.statisticsGetPoint2=$('#statistics-get-point2');
			statistics.statisticsState=$('#statistics-state');
			statistics.statisticsGridTotal=$('#statisticsGridTotal');
			
			$.post(window.ctx+'/ExamRecordsServlet?command=getClazz', function(data) {
				if (data) {
					var clazzs = eval(data);
		    		var clazzOptions = [];
		    		for (var i = 0; i < clazzs.length; i++) {
		    			clazzOptions.push('<option value=' + clazzs[i].id + '>' + clazzs[i].name + '</option>');
		    			
		    		}
		    		statistics.statisticsClazzName.append(clazzOptions.join(''));
					
				} else {
					$.messager.alert('系统提示', '获取信息失败！', 'error')
				}
				$.messager.progress('close');
			}, 'json');
			
			
			statistics.statisticsGrid.datagrid({
			    url:window.ctx+'/ExamRecordsServlet?command=liststatistics',
			    fixed: true,
			    fitColumns: true,
			    striped: true,
			    rownumbers: true,
			    pagination: true,
			    pageSize: 20,
			    pageList: [10, 20, 30, 40, 50],
			    pageNumber: 1,
			    toolbar: '#statisticsToolbar',
			    columns:[[
					{field:'user__name', title:'学员名称', width:100,align:'center'},
					{field:'qep__name', title:'试卷名称',  width:100,  align:'center'},
					{field:'startTime', title:'开始时间',width:100, align:'center'},
					{field:'submitTime', title:'提交时间', width:100, align:'center'},
					{field:'qep__totalPoint', title:'总分数', width:150, align:'center'},
					{field:'getPoint', title:'得分数', width:150, align:'center'},
					{field:'isPass', title:'是否通过', width:150, align:'center'}
			    ]],	
			    onLoadSuccess:function(data){
			    	$.post(window.ctx+'/ExamRecordsServlet?command=getTotal', function(data) {
						if (data) {
							statistics.statisticsGridTotal.html("<b style='font-size:13px'>"+data+"</b>");
						} else {
							$.messager.alert('系统提示', '获取信息失败！', 'error');
						}
					});
			    }
			});
		},
		toolbar: {
			search:function(){
				statistics.statisticsGrid.datagrid('load',{
					userName: statistics.statisticsUserName.val(),
					classId: statistics.statisticsClazzName.val(),
					paperName:statistics.statisticsPaperName.val(),
					getPoint1:statistics.statisticsGetPoint1.val(),
					getPoint2:statistics.statisticsGetPoint2.val(),
					state:statistics.statisticsState.val()
				});
				statistics.statisticsGrid.datagrid('reload');
			}
			
		}
};

	$(function(){
		statistics.init();
	});